package com.lagou.edu.dao;

import com.lagou.edu.pojo.LagouAuthCode;
import com.lagou.edu.pojo.LagouToken;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface LagouAuthCodeDao extends JpaRepository<LagouAuthCode,Long> {


    @Query(value = "SELECT * FROM lagou_auth_code WHERE email = ?1",nativeQuery = true)
    LagouAuthCode getByEmail(String email);

    LagouAuthCode getByEmailAndAndCode(String email,String code);

    @Query(value = "select * from lagou_auth_code WHERE code = ?1",nativeQuery=true)
    LagouAuthCode getOneByCode(String code);

    @Modifying
    @Query(value = "delete from lagou_auth_code where email = ?1",nativeQuery = true)
    Integer removeByEmail(String email);
}
